<%@ page pageEncoding="UTF-8"%>

<%@ taglib uri="/tags/struts-tiles" prefix="tiles"%>
<%@ taglib uri="/tags/struts-html" prefix="html"%>
<%@ taglib uri="/tags/struts-logic" prefix="logic"%>
<%@ taglib uri="/tags/struts-nested" prefix="nested"%>
<%@ taglib uri="/tags/struts-bean" prefix="bean"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix='fmt'%>

<script>
	function callback_matRemove(id) {
		if ($.pdialog._current != null) {
			$.pdialog.reload("app/conference.do?action=dialogConferenceMaterial&id=${entity.id}&op=upload");
		}
	}
</script>

<!-- Body -->
<div class="pageContent">
	<div class="panelBar">
		<ul class="toolBar">
			<c:choose>
				<c:when test="${op eq 'upload' && entity.applicant.username eq SPRING_SECURITY_LAST_USERNAME}">
					<li>
						<a class="add" target="dialog" width="400" height="180" 
							href="app/conference.do?action=dialogConferenceFileUpload&id=${entity.id}" mask="true" rel="conf_fileupload${entity.id}" title="上传会议资料文件">
							<span>上传文件</span>
						</a>
					</li>
				</c:when>
			</c:choose>
			<li>
				<a class="icon" href="app/conference.do?action=actionPackMaterail&id=${entity.id}" target="_blank" title="打包下载会议资料文件">
					<span>打包下载</span>
				</a>
				
			</li>
		</ul>
	</div>
	<table class="table" width="100%" layoutH="85">
		<thead>
			<tr>
				<th align="center">序号</th>
				<th align="center">文件名</th>
				<th align="center">文件大小</th>
				<th align="center">上传人员</th>
				<th align="center">文件创建时间</th>
				<th align="center">文件下载</th>
				<c:if test="${op eq 'upload' && entity.applicant.username eq SPRING_SECURITY_LAST_USERNAME}">
				<th align="center">文件删除</th>
				</c:if>
			</tr>
		</thead>
		<tbody>
			<logic:present name="entity" property="materials">
				<logic:iterate name="entity" property="materials" id="material" indexId="idx">
					<tr id="mat-${material.id}" ${idx % 2 == 1 ? 'style="background-color: #F5F5F5"' : ''}>
						<td>${idx+1}</td>
						<td style="text-align: left">${material.fileAttah.fileName}</td>
						<td style="text-align: right">${material.fileAttah.note}</td>
						<td style="text-align: center">${material.poster ne null ? material.poster.username : '---'}</td>
						<td><fmt:formatDate value="${material.fileAttah.createtime}" type="date" pattern="yyyy-MM-dd HH:mm:ss"/></td>
						<td>
							<a href="file-download?path=${material.fileAttah.filePath}&filename=${material.fileAttah.fileName}" target="_blank" class="oplink">下载</a>
						</td>
						<c:if test="${op eq 'upload' && entity.applicant.username eq SPRING_SECURITY_LAST_USERNAME}">
							<td>
								<a href="app/conference.do?action=actionRemoveConferenceMaterial&id=${material.id}" 
									target="ajaxToDo" title="确定要删除该文件么?" class="oplink" callback="callback_matRemove(${material.id})">删除</a>
							</td>
						</c:if>
					</tr>
				</logic:iterate>
			</logic:present>
		</tbody>
	</table>
	
	<div class="formBar">
		<ul>
			<li>
				<div class="button"><div class="buttonContent"><button type="button" class="close">关闭</button></div></div>
			</li>
		</ul>
	</div>
</div>
